package cn.fl.project.controller;

import cmm.comm.facade.framework.api.ISysDictionaryApiService;
import cmm.comm.facade.upload.api.IUploadApiService;
import cmm.comm.facade.upload.condition.SysUlFilesRecQueryCondition;
import cmm.comm.facade.upload.dto.SysUlFilesRecDTO;
import cmm.mid.core.framework.page.DataResultVO;
import cmm.mid.core.framework.page.ListPageVO;
import cmm.user.facade.system.api.IPriorityApiService;
import cmm.user.facade.system.dto.SysResourceDTO;
import cmm.web.core.framework.controller.BaseController;
import cn.cmm.base.framework.constant.BaseConstant;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.logger.eum.LogExceptionEnum;
import cn.cmm.base.framework.utils.BaseLogUtils;
import cn.cmm.base.framework.utils.CollectionUtils;
import cn.cmm.base.framework.utils.StringUtils;
import cn.cmm.cache.framework.utils.PropertiesCacheUtils;
import cn.fl.capital.constant.CapitalConstant;
import cn.fl.capital.service.ICapPayInfoService;
import cn.fl.framework.base.context.CurrentThreadContext;
import cn.fl.prjfile.constant.PrjFilesZgRepaymentConstant;
import cn.fl.project.api.IPrjPaySchMYqApiService;
import cn.fl.project.condition.PrjFileInfoQueryCondition;
import cn.fl.project.constant.PrjBscInfoConstant;
import cn.fl.project.constant.PrjFileInfoConstant;
import cn.fl.project.service.IPrjBscInfoService;
import cn.fl.project.service.IPrjFileInfoService;
import cn.fl.project.vo.PrjBscInfoVO;
import cn.fl.project.vo.PrjFileInfoVO;
import cn.fl.system.constant.SysLogConstant;
import cn.fl.system.service.ISysUlFilesRecService;
import cn.fl.system.transform.SysUlFilesRecVOTransform;
import cn.fl.system.vo.SysUlFilesRecVO;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import fl.constant.facade.framework.constant.SystemConstant;
import fl.constant.facade.framework.constant.UploadConstant;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * @Description: 付款信息表 控制层
 */
@Controller
@RequestMapping("/project/prjFileInfo")
public class PrjFileInfoController extends BaseController {
	private static final Logger logger = LoggerFactory.getLogger(PrjFileInfoController.class);

	@Autowired
	private IPrjFileInfoService prjFileInfoService;

	@Autowired
	private ISysUlFilesRecService sysUlFilesRecService;

	@Autowired
	private IPrjBscInfoService prjBscInfoService;

	@Autowired
	private IUploadApiService uploadApiService;

	@Autowired
	private ISysDictionaryApiService sysDictionaryApiService;

	@Autowired
	private IPrjPaySchMYqApiService prjPaySchMYqApiService;

	@Autowired
	private ICapPayInfoService capPayInfoService;

	@Autowired
	private IPriorityApiService priorityApiService;

	/**
	 * 到项目资料页面
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/toFileInfoListPage.do", method = {RequestMethod.GET, RequestMethod.POST})
	public ModelAndView toFileInfoListPage(HttpServletRequest request, HttpServletResponse response) {
		BaseLogUtils.info(logger, "toFileInfoListPage", "加载到项目资料页面.", CurrentThreadContext.getCurrentUserName());

		ModelAndView mav = null;

		String isDetail = request.getParameter("detailFlag");//项目详情标识
		if(null!=isDetail && "true".equals(isDetail)){
			//项目详情资料页面
			mav = new ModelAndView("/project/prjFileInfo/prjFileInfoListDetail");
		}else{
			mav = new ModelAndView("/project/prjFileInfo/prjFileInfoList");
		}
		String prjId = request.getParameter("prjId");//项目ID
		if(StringUtils.isNotEmpty(prjId)){
			PrjBscInfoVO prjBscInfoVO = this.prjBscInfoService.selectById(Long.valueOf(prjId));
			if(null!=prjBscInfoVO){
				mav.addObject("cstId", prjBscInfoVO.getCstId());
				mav.addObject("cstMgrOrgCd", prjBscInfoVO.getCstMgrOrgCd());//客户经理组织架构代码
				mav.addObject("prjTypCd", prjBscInfoVO.getPrjTypCd());//项目类型
				mav.addObject("insCode", StringUtils.isNotEmpty(prjBscInfoVO.getInsCode())?prjBscInfoVO.getInsCode():"");//机构编码
				//项目资料配置代码   车抵贷业务：PRJ022  其他：PRJ016
				if(StringUtils.isNotBlank(prjBscInfoVO.getPrjTypCd())&&PrjBscInfoConstant.PRJ_TYP_CD_CDDYW.equals(prjBscInfoVO.getPrjTypCd())){
					mav.addObject("cfgCd",PrjFileInfoConstant.CDDYW_PRJ_FILE_CFG_CD);
				}
			}
		}
		mav.addObject("prjId", prjId);
		mav.addObject("cfgCd",PrjFileInfoConstant.CODE_UL_PRJ_FILE_CFG_CD);
		String ctrlKey = request.getParameter("ctrlKey");//控制键 1.可上传、删除 2.可验证 3.不可操作
		if(StringUtils.isEmpty(ctrlKey)){//没有控制键
			String detailFlag = request.getParameter("detailFlag");//项目详情标识
			if(null!=detailFlag){//有项目详情标识参数(有值无值都包括)
				if("true".equals(detailFlag)){
					ctrlKey = "3";
				}else{
					ctrlKey = "1";
				}
			}else{
				ctrlKey = "3";
			}
		}
		//若ctrlKey==2，判断该用户该角色是否有验证的权限
		if ("2".equals(ctrlKey)) {
			List<SysResourceDTO> quitPrioList = this.priorityApiService.searchFuncWithAuth(CurrentThreadContext.getCurrentSysCd(),
					CurrentThreadContext.getCurrentRoleId(), "prjFileVerifyAuthority");
			if (CollectionUtils.isEmpty(quitPrioList)) {
				//表示该角色对prjFileVerifyAuthority（验证项目资料）没有权限
				ctrlKey = "3";
			}
		}
		mav.addObject("ctrlKey", ctrlKey);

		//********流程参数开始********//
		String preTaskIds = request.getParameter("preTaskIds");//流程上一个节点任务ID,多个以逗号分割.
		String pInstId = request.getParameter("pInstId");//流程实例ID
		mav.addObject("pInstId", pInstId);
		mav.addObject("preTaskIds", preTaskIds);
		//********流程参数结束********//
		//融资外部机构专用
		mav.addObject("pianflag",request.getParameter("pianflag"));
		mav.addObject("currentUsrId", CurrentThreadContext.getCurrentUserId());
		return mav;
	}
	/**
	 * 到租赁物资料页面
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/toPrjPrdDtlFileInfoListPage.do", method = {RequestMethod.GET, RequestMethod.POST})
	public ModelAndView toPrjPrdDtlFileInfoListPage(HttpServletRequest request, HttpServletResponse response) {
		BaseLogUtils.info(logger, "toPrjPrdDtlFileInfoListPage", "加载到租赁物资料页面.", CurrentThreadContext.getCurrentUserName());
		ModelAndView mav = new ModelAndView("/project/prjFileInfo/prjPrdDtlFileInfoList");
		String prjPrdDtlId = request.getParameter("prjPrdDtlId");//项目产品明细ID
		String ctrlKey = request.getParameter("ctrlKey");//控制键 1.可上传、下载、删除 2.可验证 3.不可操作
		String cstMgrOrgCd = request.getParameter("cstMgrOrgCd");//客户经理组织架构
		String prjId = request.getParameter("prjId");//项目ID
		String prjTypCd = request.getParameter("prjTypCd");//项目类型
		mav.addObject("ctrlKey", ctrlKey);
		mav.addObject("prjPrdDtlId", prjPrdDtlId);
		mav.addObject("cstMgrOrgCd", cstMgrOrgCd);
		mav.addObject("prjId",prjId);
		mav.addObject("prjTypCd",prjTypCd);

		//********流程参数开始********//
		String preTaskIds = request.getParameter("preTaskIds");//流程上一个节点任务ID,多个以逗号分割.
		String pInstId = request.getParameter("pInstId");//流程实例ID
		mav.addObject("pInstId", pInstId);
		mav.addObject("preTaskIds", preTaskIds);
		//********流程参数结束********//

		mav.addObject("currentUsrId", CurrentThreadContext.getCurrentUserId());
		return mav;
	}
	@RequestMapping(value = "/toPrjPrdDtlFileInfoListPageDetail.do", method = {RequestMethod.GET, RequestMethod.POST})
	public ModelAndView toPrjPrdDtlFileInfoListPageDetail(HttpServletRequest request, HttpServletResponse response) {
		BaseLogUtils.info(logger, "toPrjPrdDtlFileInfoListPageDetail", "加载到租赁物资料页面.", CurrentThreadContext.getCurrentUserName());
		ModelAndView mav = new ModelAndView("/project/prjFileInfo/prjPrdDtlFileInfoListDetail");
		String prjPrdDtlId = request.getParameter("prjPrdDtlId");//项目产品明细ID
		String ctrlKey = request.getParameter("ctrlKey");//控制键 1.可上传、下载、删除 2.可验证 3.不可操作
		String cstMgrOrgCd = request.getParameter("cstMgrOrgCd");//客户经理组织架构
		String prjId = request.getParameter("prjId");//项目ID
		String prjTypCd = request.getParameter("prjTypCd");//项目类型
		mav.addObject("ctrlKey", ctrlKey);
		mav.addObject("prjPrdDtlId", prjPrdDtlId);
		mav.addObject("cstMgrOrgCd", cstMgrOrgCd);
		mav.addObject("prjId",prjId);
		mav.addObject("prjTypCd",prjTypCd);
		//融资外部机构专用
		mav.addObject("pianflag",request.getParameter("pianflag"));
		return mav;
	}

	/**
	 * 到担保人物资料页面
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/toGuarFileInfoListPage.do", method = {RequestMethod.GET, RequestMethod.POST})
	public ModelAndView toGuarFileInfoListPage(HttpServletRequest request, HttpServletResponse response) {
		BaseLogUtils.info(logger, "toGuarFileInfoListPage", "加载到担保人物资料页面.", CurrentThreadContext.getCurrentUserName());
		ModelAndView mav = new ModelAndView("/project/prjFileInfo/prjGuarFileInfoList");
		String cstId = request.getParameter("cstId");//项目产品明细ID
		String ctrlKey = request.getParameter("ctrlKey");//控制键 1.可上传、下载、删除 2.可验证 3.不可操作
		String cstMgrOrgCd = request.getParameter("cstMgrOrgCd");//客户经理组织架构
		mav.addObject("ctrlKey", ctrlKey);
		mav.addObject("cstId", cstId);
		mav.addObject("cstMgrOrgCd", cstMgrOrgCd);

		//********流程参数开始********//
		String preTaskIds = request.getParameter("preTaskIds");//流程上一个节点任务ID,多个以逗号分割.
		String pInstId = request.getParameter("pInstId");//流程实例ID
		mav.addObject("pInstId", pInstId);
		mav.addObject("preTaskIds", preTaskIds);
		//********流程参数结束********//

		mav.addObject("currentUsrId", CurrentThreadContext.getCurrentUserId());
		return mav;
	}
	@RequestMapping(value = "/toGuarFileInfoListPageDetail.do", method = {RequestMethod.GET, RequestMethod.POST})
	public ModelAndView toGuarFileInfoListPageDetail(HttpServletRequest request, HttpServletResponse response) {
		BaseLogUtils.info(logger, "toGuarFileInfoListPageDetail", "加载到担保人物资料页面.", CurrentThreadContext.getCurrentUserName());
		ModelAndView mav = new ModelAndView("/project/prjFileInfo/prjGuarFileInfoListDetail");
		String cstId = request.getParameter("cstId");//项目产品明细ID
		String ctrlKey = request.getParameter("ctrlKey");//控制键 1.可上传、下载、删除 2.可验证 3.不可操作
		String cstMgrOrgCd = request.getParameter("cstMgrOrgCd");//客户经理组织架构
		mav.addObject("ctrlKey", ctrlKey);
		mav.addObject("cstId", cstId);
		mav.addObject("cstMgrOrgCd", cstMgrOrgCd);
		return mav;
	}
	/**
	 * 初始化客户资料配置列表
	 */
    /*@RequestMapping(value = "/initCstFileInfoCfgList.do", method = {RequestMethod.GET})
    @ResponseBody
    public Object initCstFileInfoCfgList(HttpServletRequest request, HttpServletResponse response) {
        String cstId = request.getParameter("cstId");//客户ID
        PrjFileInfoQueryCondition qc = new PrjFileInfoQueryCondition();
        if(StringUtils.isNotBlank(cstId)){
            qc.setCstId(Long.valueOf(cstId));
        }
        BaseLogUtils.info(logger, "initCstFileInfoCfgList", "初始化客户上传资料配置列表.DATA:" + JSONObject.toJSONString(qc), CurrentThreadContext.getCurrentUserName());
        List<PrjFileInfoVO> list = this.prjFileInfoService.searchCstFileInfoCfgList(qc);
        if (CollectionUtils.isNotEmpty(list)) {
            return new ListPageVO<PrjFileInfoVO>(list, list.size());
        }
        return new ListPageVO<PrjFileInfoVO>(new ArrayList<PrjFileInfoVO>(), 0);
    }*/
	/**
	 * 初始化客户资料列表
	 */
	@RequestMapping(value = "/initCstFileInfoList.do", method = {RequestMethod.GET})
	@ResponseBody
	public Object initCstFileInfoList(HttpServletRequest request, HttpServletResponse response) {
		String cstId = request.getParameter("cstId");//客户ID
		String cfgDtlCd = request.getParameter("cfgDtlCd");//子配置编号
		String cstMgrOrgCd = request.getParameter("cstMgrOrgCd");//客户经理组织架构
		PrjFileInfoQueryCondition qc = new PrjFileInfoQueryCondition();
		if(StringUtils.isNotBlank(cstId)){
			qc.setCstId(Long.valueOf(cstId));
		}
		if(StringUtils.isNotEmpty(cfgDtlCd)){
			qc.setCfgDtlCd(cfgDtlCd);
		}
		if(StringUtils.isNotEmpty(cstMgrOrgCd)){
			qc.setCstMgrOrgCd(cstMgrOrgCd);
		}
		BaseLogUtils.info(logger, "initCstFileInfoList", "初始化客户上传资料列表.DATA:" + JSONObject.toJSONString(qc), CurrentThreadContext.getCurrentUserName());
		List<PrjFileInfoVO> list = this.prjFileInfoService.searchCstFileInfoList(qc);
		if (CollectionUtils.isNotEmpty(list)) {
			return new ListPageVO<PrjFileInfoVO>(list, list.size());
		}
		return new ListPageVO<PrjFileInfoVO>(new ArrayList<PrjFileInfoVO>(), 0);
	}

	/**
	 * 初始化客户资料列表
	 */
	@RequestMapping(value = "/initCstFileInfoCertNoList.do", method = {RequestMethod.GET})
	@ResponseBody
	public Object initCstFileInfoCertNoList(HttpServletRequest request, HttpServletResponse response) {
		String cstId = request.getParameter("cstId");//客户ID
		PrjFileInfoQueryCondition qc = new PrjFileInfoQueryCondition();
		if(StringUtils.isNotBlank(cstId)){
			qc.setCstId(Long.valueOf(cstId));
		}
		BaseLogUtils.info(logger, "initCstFileInfoCertNoList", "初始化客户上传资料列表.DATA:" + JSONObject.toJSONString(qc), CurrentThreadContext.getCurrentUserName());
		List<PrjFileInfoVO> list = this.prjFileInfoService.searchCstFileInfoList(qc);
		List<PrjFileInfoVO> resList = new ArrayList<PrjFileInfoVO>();
		if(CollectionUtils.isNotEmpty(list)){
			for(PrjFileInfoVO prjFileInfoVO : list){
				if(StringUtils.isNotEmpty(prjFileInfoVO.getCfgDtlCd())
						&&(prjFileInfoVO.getCfgDtlCd().equals(PropertiesCacheUtils.getProperty(UploadConstant.CFG_DTL_CST_CERT_CD))
						||prjFileInfoVO.getCfgDtlCd().equals(PropertiesCacheUtils.getProperty(UploadConstant.CFG_DTL_CST_CERT_CD_BACK)))){
					resList.add(prjFileInfoVO);
				}
			}
		}
		if (CollectionUtils.isNotEmpty(resList)) {
			return new ListPageVO<PrjFileInfoVO>(resList, resList.size());
		}
		return new ListPageVO<PrjFileInfoVO>(new ArrayList<PrjFileInfoVO>(), 0);
	}

	/**
	 * 初始化资料列表 - 根据数据ID查询所有文件
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/initFileListByDataId.do", method = {RequestMethod.GET})
	@ResponseBody
	public Object initCstFileInfoListDetail(HttpServletRequest request, HttpServletResponse response) {
		String dataId = request.getParameter("dataId");
		String cstMgrOrgCd = request.getParameter("cstMgrOrgCd");//客户经理组织架构
		String cfgCd = request.getParameter("cfgCd");//配置编号
		if(StringUtils.isEmpty(dataId)){
			return new ListPageVO<SysUlFilesRecVO>(new ArrayList<SysUlFilesRecVO>(), 0);
		}
		SysUlFilesRecQueryCondition qc = new SysUlFilesRecQueryCondition();
		qc.setPkId(dataId);
		qc.setSysCd(CurrentThreadContext.getCurrentSysCd());
		qc.setOrgCd(cstMgrOrgCd);
		qc.setCfgCd(cfgCd);
		BaseLogUtils.info(logger, "initFileListByDataId", "初始化资料列表ByPkId.DATA:" + JSONObject.toJSONString(qc), CurrentThreadContext.getCurrentUserName());
		List<SysUlFilesRecDTO> searchSysUlFilesRecList = this.uploadApiService.searchSysUlFilesRecList(qc);
		BaseLogUtils.info(logger, "initFileListByDataId", "查询资料结果==dataId:"+dataId+",result:"+JSON.toJSONString(searchSysUlFilesRecList), CurrentThreadContext.getCurrentUserName());
		if (CollectionUtils.isNotEmpty(searchSysUlFilesRecList)) {
			List<SysUlFilesRecVO> voList = SysUlFilesRecVOTransform.toVOList(searchSysUlFilesRecList);
			Map<String, String> audStsCdMap = this.sysDictionaryApiService.searchGroupToMap(CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(), CapitalConstant.CODE_MATE_AUD_STS_CD);
			for (SysUlFilesRecVO sysUlFilesRecVO : voList) {
				if (StringUtils.isNotBlank(sysUlFilesRecVO.getAudStsCd())) {
					sysUlFilesRecVO.setAudStsCd(sysUlFilesRecVO.getAudStsCd());//验证状态
				} else {
					sysUlFilesRecVO.setAudStsCd("0");//验证状态
				}
				if (audStsCdMap != null && audStsCdMap.containsKey(sysUlFilesRecVO.getAudStsCd())) {
					sysUlFilesRecVO.setAudStsCdNm(audStsCdMap.get(sysUlFilesRecVO.getAudStsCd()));
				}
			}
			Collections.sort(voList, new Comparator<SysUlFilesRecVO>(){
				public int compare(SysUlFilesRecVO o1, SysUlFilesRecVO o2) {
					if(StringUtils.isNotEmpty(o2.getDatNm()) && StringUtils.isNotEmpty(o1.getDatNm())){
						return o2.getDatNm().compareTo(o1.getDatNm());
					}else{
						BaseLogUtils.info(logger, "initFileListByDataId", "文件记录配置项为空.o2:"+JSON.toJSONString(o2)+",o1:"+JSON.toJSONString(o1), CurrentThreadContext.getCurrentUserName());
						return 0;
					}
				}
			});
			return new ListPageVO<SysUlFilesRecVO>(voList, voList.size());
		}
		return new ListPageVO<SysUlFilesRecVO>(new ArrayList<SysUlFilesRecVO>(), 0);
	}

	/**
	 * 初始化项目资料配置列表
	 */
    /*@RequestMapping(value = "/initPrjFileInfoCfgList.do", method = {RequestMethod.GET})
    @ResponseBody
    public Object initPrjFileInfoCfgList(HttpServletRequest request, HttpServletResponse response) {
    	String prjId = request.getParameter("prjId");//项目ID
    	PrjFileInfoQueryCondition qc = new PrjFileInfoQueryCondition();
    	if(StringUtils.isNotBlank(prjId)){
    		qc.setPrjId(Long.valueOf(prjId));
    	}
    	BaseLogUtils.info(logger, "initPrjFileInfoCfgList", "初始化项目上传资料配置列表.DATA:" + JSONObject.toJSONString(qc), CurrentThreadContext.getCurrentUserName());
    	List<PrjFileInfoVO> list = this.prjFileInfoService.searchPrjFileInfoCfgList(qc);
    	if (CollectionUtils.isNotEmpty(list)) {
    		return new ListPageVO<PrjFileInfoVO>(list, list.size());
    	}
    	return new ListPageVO<PrjFileInfoVO>(new ArrayList<PrjFileInfoVO>(), 0);
    }*/

	/**
	 * 初始化项目资料列表
	 */
	@RequestMapping(value = "/initPrjFileInfoList.do", method = {RequestMethod.GET})
	@ResponseBody
	public Object initPrjFileInfoList(HttpServletRequest request, HttpServletResponse response) {
		String prjId = request.getParameter("prjId");//项目ID
		String cfgDtlCd = request.getParameter("cfgDtlCd");//子配置编号
		String cstMgrOrgCd = request.getParameter("cstMgrOrgCd");//客户经理组织架构
		String prjTypCd = request.getParameter("prjTypCd");//项目类型
		PrjFileInfoQueryCondition qc = new PrjFileInfoQueryCondition();
		if(StringUtils.isNotBlank(prjId)){
			qc.setPrjId(Long.valueOf(prjId));
		}
		if(StringUtils.isNotEmpty(cfgDtlCd)){
			qc.setCfgDtlCd(cfgDtlCd);
		}
		if(StringUtils.isNotEmpty(cstMgrOrgCd)){
			qc.setCstMgrOrgCd(cstMgrOrgCd);
		}
		if(StringUtils.isNotBlank(prjTypCd)){
			qc.setPrjTypCd(prjTypCd);
		}
		BaseLogUtils.info(logger, "initPrjFileInfoList", "初始化项目上传资料列表.DATA:" + JSONObject.toJSONString(qc), CurrentThreadContext.getCurrentUserName());
		List<PrjFileInfoVO> list = this.prjFileInfoService.searchPrjFileInfoList(qc);
		if (CollectionUtils.isNotEmpty(list)) {
			return new ListPageVO<PrjFileInfoVO>(list, list.size());
		}
		return new ListPageVO<PrjFileInfoVO>(new ArrayList<PrjFileInfoVO>(), 0);
	}
	/**
	 * 初始化项目资料列表 - 狮桥对客合同
	 */
	@RequestMapping(value = "/initPrjLionCstFileInfoList.do", method = {RequestMethod.GET})
	@ResponseBody
	public Object initPrjLionCstFileInfoList(HttpServletRequest request, HttpServletResponse response) {
		String prjId = request.getParameter("prjId");//项目ID
		String cfgDtlCd = request.getParameter("cfgDtlCd");//子配置编号
		String cstMgrOrgCd = request.getParameter("cstMgrOrgCd");//客户经理组织架构
		PrjFileInfoQueryCondition qc = new PrjFileInfoQueryCondition();
		if(StringUtils.isNotBlank(prjId)){
			qc.setPrjId(Long.valueOf(prjId));
		}
		if(StringUtils.isNotEmpty(cfgDtlCd)){
			qc.setCfgDtlCd(cfgDtlCd);
		}
		if(StringUtils.isNotEmpty(cstMgrOrgCd)){
			qc.setCstMgrOrgCd(cstMgrOrgCd);
		}
		BaseLogUtils.info(logger, "initPrjLionCstFileInfoList", "初始化项目上传资料-狮桥对客合同列表.DATA:" + JSONObject.toJSONString(qc), CurrentThreadContext.getCurrentUserName());
		List<PrjFileInfoVO> list = this.prjFileInfoService.searchPrjLionCstFileInfoList(qc);
		if (CollectionUtils.isNotEmpty(list)) {
			return new ListPageVO<PrjFileInfoVO>(list, list.size());
		}
		return new ListPageVO<PrjFileInfoVO>(new ArrayList<PrjFileInfoVO>(), 0);
	}
	/**
	 * 初始化项目资料列表 - 三方对客合同
	 */
	@RequestMapping(value = "/initPrjTrigonalCstFileInfoList.do", method = {RequestMethod.GET})
	@ResponseBody
	public Object initPrjTrigonalCstFileInfoList(HttpServletRequest request, HttpServletResponse response) {
		String prjId = request.getParameter("prjId");//项目ID
		String cfgDtlCd = request.getParameter("cfgDtlCd");//子配置编号
		String cstMgrOrgCd = request.getParameter("cstMgrOrgCd");//客户经理组织架构
		PrjFileInfoQueryCondition qc = new PrjFileInfoQueryCondition();
		if(StringUtils.isNotBlank(prjId)){
			qc.setPrjId(Long.valueOf(prjId));
		}
		if(StringUtils.isNotEmpty(cfgDtlCd)){
			qc.setCfgDtlCd(cfgDtlCd);
		}
		if(StringUtils.isNotEmpty(cstMgrOrgCd)){
			qc.setCstMgrOrgCd(cstMgrOrgCd);
		}
		BaseLogUtils.info(logger, "initPrjTrigonalCstFileInfoList", "初始化项目上传资料-三方对客合同列表.DATA:" + JSONObject.toJSONString(qc), CurrentThreadContext.getCurrentUserName());
		List<PrjFileInfoVO> list = this.prjFileInfoService.searchPrjTrigonalCstFileInfoList(qc);
		if (CollectionUtils.isNotEmpty(list)) {
			return new ListPageVO<PrjFileInfoVO>(list, list.size());
		}
		return new ListPageVO<PrjFileInfoVO>(new ArrayList<PrjFileInfoVO>(), 0);
	}

	/**
	 * 根据 主键ID 配置编号 组织架构 初始化资料列表
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/initFileInfoListByCfgCd.do", method = {RequestMethod.GET})
	@ResponseBody
	public Object initFileInfoListByCfgCd(HttpServletRequest request, HttpServletResponse response) {
		String dataId = request.getParameter("dataId");//业务主键ID
		String cfgCd = request.getParameter("cfgCd");//子配置编号
		String cstMgrOrgCd = request.getParameter("cstMgrOrgCd");//客户经理组织架构
		PrjFileInfoQueryCondition qc = new PrjFileInfoQueryCondition();
		if(StringUtils.isNotBlank(dataId)){
			qc.setDataId(Long.valueOf(dataId));
		}
		if(StringUtils.isNotEmpty(cfgCd)){
			qc.setCfgCd(cfgCd);
		}
		if(StringUtils.isNotEmpty(cstMgrOrgCd)){
			qc.setCstMgrOrgCd(cstMgrOrgCd);
		}
		BaseLogUtils.info(logger, "initPrjTrigonalCstFileInfoList", "初始化项目上传资料-三方对客合同列表.DATA:" + JSONObject.toJSONString(qc), CurrentThreadContext.getCurrentUserName());
		List<PrjFileInfoVO> list = this.prjFileInfoService.searchFileInfoListByCfgCd(qc);
		if (CollectionUtils.isNotEmpty(list)) {
			return new ListPageVO<PrjFileInfoVO>(list, list.size());
		}
		return new ListPageVO<PrjFileInfoVO>(new ArrayList<PrjFileInfoVO>(), 0);
	}
	/**
	 * 初始化租赁物资料配置列表
	 */
    /*@RequestMapping(value = "/initPrjPrdDtlFileInfoCfgList.do", method = {RequestMethod.GET})
    @ResponseBody
    public Object initPrjPrdDtlFileInfoCfgList(HttpServletRequest request, HttpServletResponse response) {
    	String prjPrdDtlId = request.getParameter("prjPrdDtlId");//项目产品明细ID
    	PrjFileInfoQueryCondition qc = new PrjFileInfoQueryCondition();
    	if(StringUtils.isNotBlank(prjPrdDtlId)){
    		qc.setPrjPrdDtlId(Long.valueOf(prjPrdDtlId));
    	}
    	BaseLogUtils.info(logger, "initPrjPrdDtlFileInfoCfgList", "初始化租赁物上传资料配置列表.DATA:" + JSONObject.toJSONString(qc), CurrentThreadContext.getCurrentUserName());
    	List<PrjFileInfoVO> list = this.prjFileInfoService.searchPrjPrdDtlFileInfoCfgList(qc);
    	if (CollectionUtils.isNotEmpty(list)) {
    		return new ListPageVO<PrjFileInfoVO>(list, list.size());
    	}
    	return new ListPageVO<PrjFileInfoVO>(new ArrayList<PrjFileInfoVO>(), 0);
    }*/

	/**
	 * 初始化租赁物资料列表
	 */
	@RequestMapping(value = "/initPrjPrdDtlFileInfoList.do", method = {RequestMethod.GET})
	@ResponseBody
	public Object initPrjPrdDtlFileInfoList(HttpServletRequest request, HttpServletResponse response) {
		String prjPrdDtlId = request.getParameter("prjPrdDtlId");//项目产品明细ID
		String cfgDtlCd = request.getParameter("cfgDtlCd");//子配置编号
		String cstMgrOrgCd = request.getParameter("cstMgrOrgCd");//客户经理组织架构代码
		String prjTypCd = request.getParameter("prjTypCd");//项目类型
		String prjId = request.getParameter("prjId");//项目ID
		String fromCddFlag = request.getParameter("fromCddFlag");//车抵贷标识
		PrjFileInfoQueryCondition qc = new PrjFileInfoQueryCondition();
		if(StringUtils.isNotBlank(prjPrdDtlId)){
			qc.setPrjPrdDtlId(Long.valueOf(prjPrdDtlId));
		}
		if(StringUtils.isNotEmpty(cfgDtlCd)){
			qc.setCfgDtlCd(cfgDtlCd);
		}
		if(StringUtils.isNotEmpty(cstMgrOrgCd)){
			qc.setCstMgrOrgCd(cstMgrOrgCd);
		}
		if(StringUtils.isNotBlank(prjId)){
			qc.setPrjId(Long.valueOf(prjId));
		}
		if(StringUtils.isNotBlank(prjTypCd)){
			qc.setPrjTypCd(prjTypCd);
		}
		BaseLogUtils.info(logger, "initPrjPrdDtlFileInfoList", "初始化租赁物上传资料列表.DATA:" + JSONObject.toJSONString(qc), CurrentThreadContext.getCurrentUserName());
		List<PrjFileInfoVO> list = this.prjFileInfoService.searchPrjPrdDtlFileInfoList(qc);
		
		if(StringUtils.isNotEmpty(fromCddFlag) && CollectionUtils.isNotEmpty(list)){
    		List<PrjFileInfoVO> newList = new ArrayList<PrjFileInfoVO>();
    		for (PrjFileInfoVO prjFileInfoVO : list) {
				if("13".equals(prjFileInfoVO.getCfgDtlCd()) || "240".equals(prjFileInfoVO.getCfgDtlCd())){
					newList.add(prjFileInfoVO);
				}
			}
    		list = newList;
    	}
		if (CollectionUtils.isNotEmpty(list)) {
			return new ListPageVO<PrjFileInfoVO>(list, list.size());
		}
		return new ListPageVO<PrjFileInfoVO>(new ArrayList<PrjFileInfoVO>(), 0);
	}

	/********************
	 * 上传客户资料文件
	 *******************/
	@RequestMapping(value = "/uploadCstFile.do", method = {RequestMethod.POST})
	@ResponseBody
	public Object uploadCstFile(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_FILE_UPLOAD_SUCC);
		String fileParams = request.getParameter("fileParams");
		String cfgCd = request.getParameter("cfgCd");
		String cfgDtlCd = request.getParameter("cfgDtlCd");
		String orgCd = request.getParameter("orgCd");
		String cstId = request.getParameter("cstId");
		String prjCstId = request.getParameter("prjCstId");
		if (StringUtils.isBlank(cstId)) {
			BaseLogUtils.error(logger, "uploadCstFile", "上传项目资料文件失败,主键客户ID为空==>cfgCd=" + cfgCd + ",cfgDtlCd=" + cfgDtlCd + ",orgCd=" + orgCd);
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_FILE_UPLOAD_FAIL);
		} else {
			boolean flag = false;
			if (PrjFileInfoConstant.ZRRGUAR_PRD_FILE_CFG_CD.equals(cfgCd) || PrjFileInfoConstant.FRGUAR_PRD_FILE_CFG_CD.equals(cfgCd)){
				flag = this.sysUlFilesRecService.addAttchmnt(prjCstId, fileParams, cfgCd, cfgDtlCd, "PRJ_CST_BSC_INFO", null, null, null, false, orgCd);
			}else {
				flag = this.sysUlFilesRecService.addAttchmnt(cstId, fileParams, cfgCd, cfgDtlCd, "CST_BSC_INFO", null, null, null, false, orgCd);
			}
			if (!flag) {
				BaseLogUtils.error(logger, "uploadCstFile", "上传项目资料文件失败==>cstId=" + cstId + ",cfgCd=" + cfgCd + ",cfgDtlCd=" + cfgDtlCd + ",file=" + fileParams );
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_FILE_UPLOAD_FAIL);
				return result;
			}
			//result.setData(this.capPayInfoService.getPayMateCnt(Long.valueOf(prjPrdDtlId)));
			BaseLogUtils.info(logger, "uploadCstFile", "上传项目资料文件成功==>cstId=" + cstId + ",cfgCd=" + cfgCd + ",cfgDtlCd=" + cfgDtlCd + ",orgCd=" + orgCd);
		}
		return result;
	}
	/********************
	 * 上传项目资料文件
	 *******************/
	@RequestMapping(value = "/uploadPrjFile.do", method = {RequestMethod.POST})
	@ResponseBody
	public Object uploadPrjFile(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_FILE_UPLOAD_SUCC);
		String fileParams = request.getParameter("fileParams");
		String cfgCd = request.getParameter("cfgCd");
		String cfgDtlCd = request.getParameter("cfgDtlCd");
		String orgCd = request.getParameter("orgCd");
		String prjId = request.getParameter("prjId");
		if (StringUtils.isBlank(prjId)) {
			BaseLogUtils.error(logger, "uploadPrjFile", "上传项目资料文件失败,主键项目ID为空==>cfgCd=" + cfgCd + ",cfgDtlCd=" + cfgDtlCd);
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_FILE_UPLOAD_FAIL);
		} else {
			boolean flag = this.sysUlFilesRecService.addAttchmnt(prjId, fileParams, cfgCd, cfgDtlCd, "PRJ_BSC_INFO", null, null, null, false, orgCd);
			if (!flag) {
				BaseLogUtils.error(logger, "uploadPrjFile", "上传项目资料文件失败==>prjId=" + prjId + ",cfgCd=" + cfgCd + ",cfgDtlCd=" + cfgDtlCd + ",file=" + fileParams);
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_FILE_UPLOAD_FAIL);
				return result;
			}
			//result.setData(this.capPayInfoService.getPayMateCnt(Long.valueOf(prjPrdDtlId)));
			BaseLogUtils.info(logger, "uploadPrjFile", "上传项目资料文件成功==>prjId=" + prjId + ",cfgCd=" + cfgCd + ",cfgDtlCd=" + cfgDtlCd);
		}
		return result;
	}
	/********************
	 * 上传租赁物资料文件
	 *******************/
	@RequestMapping(value = "/uploadPrjPrdDtlFile.do", method = {RequestMethod.POST})
	@ResponseBody
	public Object uploadPrjPrdDtlFile(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_FILE_UPLOAD_SUCC);
		String fileParams = request.getParameter("fileParams");
		String cfgCd = request.getParameter("cfgCd");
		String cfgDtlCd = request.getParameter("cfgDtlCd");
		String orgCd = request.getParameter("orgCd");
		String prjPrdDtlId = request.getParameter("prjPrdDtlId");
		if (StringUtils.isBlank(prjPrdDtlId)) {
			BaseLogUtils.error(logger, "uploadPrjPrdDtlFile", "上传租赁物资料文件失败,主键项目产品明细ID为空==>cfgCd=" + cfgCd + ",cfgDtlCd=" + cfgDtlCd);
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_FILE_UPLOAD_FAIL);
		} else {
			boolean flag = this.sysUlFilesRecService.addAttchmnt(prjPrdDtlId, fileParams, cfgCd, cfgDtlCd, "PRJ_PRD_DTL", null, null, null, false, orgCd);
			if (!flag) {
				BaseLogUtils.error(logger, "uploadPrjPrdDtlFile", "上传租赁物资料文件失败==>prjPrdDtlId=" + prjPrdDtlId + ",cfgCd=" + cfgCd + ",cfgDtlCd=" + cfgDtlCd + ",file=" + fileParams);
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_FILE_UPLOAD_FAIL);
				return result;
			}
			//result.setData(this.capPayInfoService.getPayMateCnt(Long.valueOf(prjPrdDtlId)));
			BaseLogUtils.info(logger, "uploadPrjPrdDtlFile", "上传租赁物资料文件成功==>prjPrdDtlId=" + prjPrdDtlId + ",cfgCd=" + cfgCd + ",cfgDtlCd=" + cfgDtlCd);
		}
		return result;
	}
	/********************
	 * 上传保单资料文件
	 *******************/
	@RequestMapping(value = "/uploadInsPlcFile.do", method = {RequestMethod.POST})
	@ResponseBody
	public Object uploadInsPlcFile(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_FILE_UPLOAD_SUCC);
		String fileParams = request.getParameter("fileParams");
		String cfgCd = request.getParameter("cfgCd");
		String cfgDtlCd = request.getParameter("cfgDtlCd");
		String orgCd = request.getParameter("orgCd");
		String plcId = request.getParameter("plcId");
		if (StringUtils.isBlank(plcId)) {
			BaseLogUtils.error(logger, "uploadInsPlcFile", "上传保单资料文件失败,主键保单ID为空==>cfgCd=" + cfgCd + ",cfgDtlCd=" + cfgDtlCd);
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_FILE_UPLOAD_FAIL);
		} else {
			boolean flag = this.sysUlFilesRecService.addAttchmnt(plcId, fileParams, cfgCd, cfgDtlCd, "INS_PLC_BSC_INFO", null, null, null, false, orgCd);
			if (!flag) {
				BaseLogUtils.error(logger, "uploadInsPlcFile", "上传保单资料文件失败==>plcId=" + plcId + ",cfgCd=" + cfgCd + ",cfgDtlCd=" + cfgDtlCd + ",file=" + fileParams);
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_FILE_UPLOAD_FAIL);
				return result;
			}
			//result.setData(this.capPayInfoService.getPayMateCnt(Long.valueOf(prjPrdDtlId)));
			BaseLogUtils.info(logger, "uploadInsPlcFile", "上传保单资料文件成功==>plcId=" + plcId + ",cfgCd=" + cfgCd + ",cfgDtlCd=" + cfgDtlCd);
		}
		return result;
	}

	/**
	 * 修改项目资料的验证状态
	 *
	 * @param request
	 * @param response
	 * @return
	 * @throws BaseException
	 */
	@RequestMapping(value = "/modifyFileAudStsCd.do", method = {RequestMethod.POST})
	@ResponseBody
	public DataResultVO modifyFileAudStsCd(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
		String fileId = request.getParameter("fileId");
		String audStsCd = request.getParameter("audStsCd");
		if (StringUtils.isEmpty(fileId)) {
			BaseLogUtils.info(logger, "modifyFileAudStsCd", "修改项目资料的验证状态==>资料ID为空");
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("验证操作失败");
			return result;
		}
		if (StringUtils.isBlank(audStsCd)) {
			BaseLogUtils.info(logger, "modifyFileAudStsCd", "修改项目资料的验证状态==>验证状态为空");
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("验证操作失败");
			return result;
		}
		boolean success = this.prjFileInfoService.modifyFileAudStsCd(Long.valueOf(fileId), audStsCd);
		BaseLogUtils.info(logger, "", "修改项目资料的验证状态,id=" + fileId + ",audStsCd=" + audStsCd + ",success=" + success, CurrentThreadContext.getCurrentUserName());
		if (!success) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("验证操作失败");
		}
		return result;
	}

	/**
	 * 删除项目资料
	 *
	 * @param request
	 * @param response
	 * @return
	 * @throws BaseException
	 */
	@RequestMapping(value = "/removeFile.do", method = {RequestMethod.POST})
	@ResponseBody
	public DataResultVO removeFile(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_DELETE_SUCC);
		String fileId = request.getParameter("fileId");
		String marks = request.getParameter("marks");
		if (StringUtils.isEmpty(fileId)) {
			BaseLogUtils.info(logger, "removeFile", "删除项目资料==>资料ID为空");
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DELETE_FAIL);
			return result;
		}
		boolean success = false;
		if(StringUtils.isNotBlank(marks) && marks.equals(BaseConstant.IS_YESNO_YES_STR)){//附件配置修改
			SysUlFilesRecVO sysUlFilesRecVO = this.sysUlFilesRecService.selectById(Long.valueOf(fileId));
			BaseLogUtils.info(logger,"removeFile","附件配置修改源数据：" + JSON.toJSONString(sysUlFilesRecVO));
			sysUlFilesRecVO.setCfgCd("CST001");
			sysUlFilesRecVO.setCfgDtlCd("10");
			List<SysUlFilesRecVO> sysUlFilesRecVOList = new ArrayList<SysUlFilesRecVO>();
			sysUlFilesRecVOList.add(sysUlFilesRecVO);
			this.sysUlFilesRecService.modifySysUlFilesRecList(sysUlFilesRecVOList);
			success = true;
			BaseLogUtils.info(logger,"removeFile","附件配置修改结果：" + success);
		}else{
			List<SysUlFilesRecDTO> sysUlFilesRecDTOList = new ArrayList<SysUlFilesRecDTO>();
			SysUlFilesRecDTO sysUlFilesRec = new SysUlFilesRecDTO();
			sysUlFilesRec.setId(Long.valueOf(fileId));
			sysUlFilesRec.setIsDel(BaseConstant.IS_YESNO_YES);
			sysUlFilesRec.setMdfTm(new Date());
			sysUlFilesRec.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
			sysUlFilesRecDTOList.add(sysUlFilesRec);
			this.uploadApiService.modifySysUlFilesRecList(sysUlFilesRecDTOList);
			success = true;
		}
		BaseLogUtils.info(logger, "", "删除项目资料,id=" + fileId + ",success=" + success, CurrentThreadContext.getCurrentUserName());
		if (!success) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DELETE_FAIL);
		}
        /*if (StringUtils.isNotEmpty(id)) {
            result.setData(this.capPayInfoService.getPayMateCnt(Long.valueOf(id)));
        }*/
		return result;
	}


	/**
	 * 初始化项目资方文件
	 */
	@RequestMapping(value = "/initPrjPayAssetFileList.do", method = {RequestMethod.GET})
	@ResponseBody
	public Object initPrjPayAssetFileList(HttpServletRequest request, HttpServletResponse response) {
		String capPayId = request.getParameter("capPayId");//付款信息ID
		String prjId = request.getParameter("prjId");//项目ID
		String cfgCd = PrjFilesZgRepaymentConstant.CFG_CD_ZG_COMMON;
		String cfgDtlCd = PrjFilesZgRepaymentConstant.CFG_DTL_CD_ZG_COMMON;
		BaseLogUtils.info(logger, "initPrjPayAssetFileList", "加载项目资方文件开始 ,prjId:"+prjId);
		if(StringUtils.isEmpty(prjId)){
			List<SysUlFilesRecVO> sysUlFiles = new ArrayList<SysUlFilesRecVO>();
			BaseLogUtils.error(logger, "initPrjPayAssetFileList", "请求信息为空");
			SysUlFilesRecVO sysUlFilesRecVO = new SysUlFilesRecVO();
			sysUlFilesRecVO.setPkId(prjId);
			sysUlFilesRecVO.setCfgCd(cfgCd);
			sysUlFilesRecVO.setCfgDtlCd(cfgDtlCd);
			sysUlFiles.add(sysUlFilesRecVO);
			return new ListPageVO<SysUlFilesRecVO>(sysUlFiles, 1);
			// return new ListPageVO<SysUlFilesRecVO>(new ArrayList<SysUlFilesRecVO>(), 0);
		}
		BaseLogUtils.newWebLogger("===查询项目信息Start===prjId:" + prjId).info();
		PrjBscInfoVO prjBscInfoVO = this.prjBscInfoService.selectById(Long.valueOf(prjId));
		BaseLogUtils.newWebLogger("===查询项目信息End===prjId:" + prjId + ",prjBscInfoVO:" + JSON.toJSONString(prjBscInfoVO)).info();
		List<String> pkIdList = new ArrayList<>();
		pkIdList.add(prjId);
		SysUlFilesRecQueryCondition sysUlFilesRecQueryCondition = new SysUlFilesRecQueryCondition();
		sysUlFilesRecQueryCondition.setCfgCd(cfgCd);
		sysUlFilesRecQueryCondition.setCfgDtlCd(cfgDtlCd);
		sysUlFilesRecQueryCondition.setSysCd(PropertiesCacheUtils.getProperty(SystemConstant.FL_SERVICE_CD));
		sysUlFilesRecQueryCondition.setOrgCd(PropertiesCacheUtils.getProperty(SystemConstant.FL_ORG_CD));
		sysUlFilesRecQueryCondition.setPkIdList(pkIdList);
		List<SysUlFilesRecVO> list = this.sysUlFilesRecService.searchList(sysUlFilesRecQueryCondition);
		BaseLogUtils.info(logger, "initPrjFileInfoList", "加载项目资方文件列表.DATA:" + JSONObject.toJSONString(list), CurrentThreadContext.getCurrentUserName());
		if (CollectionUtils.isEmpty(list)) {
			SysUlFilesRecVO sysUlFilesRecVO = new SysUlFilesRecVO();
			sysUlFilesRecVO.setPkId(prjId);
			sysUlFilesRecVO.setCfgCd(cfgCd);
			sysUlFilesRecVO.setCfgDtlCd(cfgDtlCd);
			if (PrjBscInfoConstant.PRJ_INS_CODE_QDGHBANK.equals(prjBscInfoVO.getInsCode())) {
				sysUlFilesRecVO.setAudStsCdNm("未上传");
			}
			list.add(sysUlFilesRecVO);
		} else {
			if (PrjBscInfoConstant.PRJ_INS_CODE_QDGHBANK.equals(prjBscInfoVO.getInsCode())) {
				for (SysUlFilesRecVO sysUlFilesRecVO : list) {
					if (StringUtils.isNotBlank(sysUlFilesRecVO.getAudStsCd()) && "3".equals(sysUlFilesRecVO.getAudStsCd())) {
						sysUlFilesRecVO.setAudStsCdNm("成功");
					}
				}
			}
		}
		return new ListPageVO<SysUlFilesRecVO>(list, list.size());
		// return new ListPageVO<SysUlFilesRecVO>(new ArrayList<SysUlFilesRecVO>(), 0);
	}

	/********************
	 * 上传项目资方文件
	 *******************/
	@RequestMapping(value = "/uploadPrjPayAssetFile.do", method = {RequestMethod.POST})
	@ResponseBody
	public Object uploadPrjPayAssetFile(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_FILE_UPLOAD_SUCC);
		String fileParams = request.getParameter("fileParams");
		String cfgCd = PrjFilesZgRepaymentConstant.CFG_CD_ZG_COMMON;
		String cfgDtlCd = PrjFilesZgRepaymentConstant.CFG_DTL_CD_ZG_COMMON;
		String capPayId = request.getParameter("capPayId");// 付款信息ID
		String prjId = request.getParameter("prjId"); //项目ID
		if (StringUtils.isBlank(prjId)) {
			BaseLogUtils.error(logger, "uploadPrjPayAssetFile", "上传项目资料文件失败,主键支付表ID为空==>cfgCd=" + cfgCd);
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_FILE_UPLOAD_FAIL);
		} else {
            List<String> pkIdList = new ArrayList<>();
            pkIdList.add(prjId);
            SysUlFilesRecQueryCondition sysUlFilesRecQueryCondition = new SysUlFilesRecQueryCondition();
            sysUlFilesRecQueryCondition.setCfgCd(cfgCd);
			sysUlFilesRecQueryCondition.setCfgDtlCd(cfgDtlCd);
			sysUlFilesRecQueryCondition.setSysCd(PropertiesCacheUtils.getProperty(SystemConstant.FL_SERVICE_CD));
            sysUlFilesRecQueryCondition.setOrgCd(PropertiesCacheUtils.getProperty(SystemConstant.FL_ORG_CD));
            sysUlFilesRecQueryCondition.setPkIdList(pkIdList);
            List<SysUlFilesRecVO> list = this.sysUlFilesRecService.searchList(sysUlFilesRecQueryCondition);
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            String nowDate = sdf.format(new Date());
            if(CollectionUtils.isNotEmpty(list)){
                SysUlFilesRecVO sysUlFilesRecVO = list.get(0);
                // if(!nowDate.equals(sysUlFilesRecVO.getCfgDtlCd())){  // 支持当天（00:00～24:00）重复上传
                //     result.setSuccess(BaseConstant.IS_YESNO_NO);
                //     result.setInfo("仅支持当天（00:00～24:00）重复上传");
                //     return result;
                // }
                nowDate = sysUlFilesRecVO.getFileRem();
				List<Long> ids = new ArrayList<>();
				ids.add(sysUlFilesRecVO.getId());
				BaseLogUtils.info(logger, "initPrjFileInfoList", "删除旧文件： ids:" + JSONObject.toJSONString(ids), CurrentThreadContext.getCurrentUserName());
				boolean flag = this.sysUlFilesRecService.removeByIds(ids);
				if (!flag) {
					BaseLogUtils.error(logger, "uploadPrjPayAssetFile", "上传项目资料文件失败==>prjId=" + prjId + ",cfgCd=" + cfgCd + ",file=" + fileParams);
					result.setSuccess(BaseConstant.IS_YESNO_NO);
					result.setInfo(SysLogConstant.LOG_FILE_UPLOAD_FAIL);
					return result;
				}
            }
			BaseLogUtils.info(logger, "initPrjFileInfoList", "加载项目资方文件列表.DATA:" + JSONObject.toJSONString(list), CurrentThreadContext.getCurrentUserName());
			boolean flag = this.sysUlFilesRecService.addAttchmntByOneSys(prjId, fileParams, cfgCd, cfgDtlCd, "CAP_PAY_INFO", nowDate, null, null, true, PropertiesCacheUtils.getProperty(SystemConstant.FL_ORG_CD), PropertiesCacheUtils.getProperty(SystemConstant.FL_SERVICE_CD));
			if (!flag) {
				BaseLogUtils.error(logger, "uploadPrjPayAssetFile", "上传项目资料文件失败==>prjId=" + prjId + ",cfgCd=" + cfgCd + ",file=" + fileParams);
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_FILE_UPLOAD_FAIL);
				return result;
			}
			//result.setData(this.capPayInfoService.getPayMateCnt(Long.valueOf(prjPrdDtlId)));
			BaseLogUtils.info(logger, "uploadPrjPayAssetFile", "上传项目资料文件成功==>prjId=" + prjId + ",cfgCd=" + cfgCd);
		}
		return result;
	}
	/**
	 * 批量修改项目资料的验证状态
	 *
	 * @param request
	 * @param response
	 * @return
	 * @throws BaseException
	 */
	@RequestMapping(value = "/modifyFileAudStsCdList.do", method = {RequestMethod.POST})
	@ResponseBody
	public DataResultVO modifyFileAudStsCdList(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
		String fileIds = request.getParameter("fileIds");
		if (StringUtils.isEmpty(fileIds)) {
			BaseLogUtils.info(logger, "modifyFileAudStsCd", "修改项目资料的验证状态==>资料ID集合为空");
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("一键验证操作失败");
			return result;
		}
		List<Long> fileIdList = new ArrayList<Long>();
		JSONArray idsArray =JSONArray.parseArray(fileIds);
		for (Object idObj : idsArray) {
			fileIdList.add(Long.valueOf(idObj.toString()));
		}
		BaseLogUtils.newLogger("批量修改项目资料验证状态Begin:fileIdList=" + JSON.toJSONString(fileIdList)).info();
		boolean success = this.prjFileInfoService.modifyFileAudStsCdList(fileIdList, "1");
		BaseLogUtils.newLogger("批量修改项目资料验证状态End:success=" + success + ",currUsr=" + CurrentThreadContext.getCurrentUserName()).info();
		if (!success) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("一键验证操作失败");
		}
		return result;
	}

	/**
	 * 线上退车--初始化文件信息
	 */
	@RequestMapping(value = "/initPrdDtlBackOffFileList.do", method = {RequestMethod.GET})
	@ResponseBody
	public Object initPrdDtlBackOffFileList(HttpServletRequest request, HttpServletResponse response) {
        String prjPrdDtlId = request.getParameter("prjPrdDtlId");//项目产品明细ID
		String prjId = request.getParameter("prjId");//项目ID
		String cfgCd = request.getParameter("cfgCd");//配置编号
		BaseLogUtils.newWebLogger("加载文件开始, prjId:" + prjId).info();
		PrjFileInfoQueryCondition prjFileInfoQueryCondition = new PrjFileInfoQueryCondition();
		if(StringUtils.isNotBlank(prjPrdDtlId)){
			prjFileInfoQueryCondition.setPrjPrdDtlId(Long.valueOf(prjPrdDtlId));
		}
		if(StringUtils.isNotEmpty(cfgCd)){
			prjFileInfoQueryCondition.setCfgCd(cfgCd);
		}
		if(StringUtils.isNotBlank(prjId)){
			prjFileInfoQueryCondition.setPrjId(Long.valueOf(prjId));
		}
		BaseLogUtils.newWebLogger("===加载文件列表入参Start===sysUlFilesRecQueryCondition:" + JSONObject.toJSONString(prjFileInfoQueryCondition)).info();
		List<PrjFileInfoVO> list = this.prjFileInfoService.searchPrdDtlBackOffFileList(prjFileInfoQueryCondition);
		BaseLogUtils.newWebLogger("===加载文件列表End===list:" + JSONObject.toJSONString(list)).info();
		if (CollectionUtils.isNotEmpty(list)) {
			return new ListPageVO<PrjFileInfoVO>(list, list.size());
		}
		return new ListPageVO<PrjFileInfoVO>(new ArrayList<PrjFileInfoVO>(), 0);
	}
}

